wayland: Don't use g_error() on connection lost
authorOlivier Fourdan <ofourdan@redhat.com>
Fri, 27 Feb 2015 12:06:29 +0000 (13:06 +0100)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 27 Feb 2015 21:26:39 +0000 (16:26 -0500)
When the Wayland compositor vanishes, all applications connected will
receive a SIGPIPE as soon as they try to use wl_display_dispatch().

Do not use g_error() to terminate the applications when this occurs,
g_error() means an error in the application while here it's not truly
the case.

Use g_warning() and exit() instead.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
https://bugzilla.gnome.org/show_bug.cgi?id=745289

gdk/wayland/gdkeventsource.c

index 1595a3079abce44eb216abba95ed653b284f5b75..d675ce91e7d19fcc06026a4305d13fabeacbe0df 100644 (file)
@@ -20,6 +20,7 @@
 #include "gdkinternals.h"
 #include "gdkprivate-wayland.h"
 
+#include <stdlib.h>
 #include <errno.h>
 
 typedef struct _GdkWaylandEventSource {
@@ -160,11 +161,17 @@ _gdk_wayland_display_queue_events (GdkDisplay *display)
   if (source->pfd.revents & G_IO_IN)
     {
       if (wl_display_dispatch (display_wayland->wl_display) < 0)
-        g_error ("Error dispatching display: %s", g_strerror (errno));
+        {
+          g_warning ("Error %d (%s) dispatching to Wayland display.",
+                     errno, g_strerror (errno));
+          exit (1);
+        }
     }
 
   if (source->pfd.revents & (G_IO_ERR | G_IO_HUP))
-    g_error ("Lost connection to wayland compositor");
-
+    {
+      g_warning ("Lost connection to Wayland compositor.");
+      exit (1);
+    }
   source->pfd.revents = 0;
 }